package com.sharkburner.aeris.ui.module.site.composition;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.sharkburner.aeris.ui.module.site.component.AddSiteComponent;
import com.sharkburner.aeris.ui.module.site.component.SourceListComponent;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.VerticalLayout;

@Component
public class SiteLayout extends VerticalLayout {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private HorizontalLayout mainLayout;
	private VerticalLayout siteLayout;
	private VerticalLayout siteDetailLayout;
	private VerticalLayout filterLayout;

	@Autowired
	private AddSiteComponent addSiteComposition;

	@Autowired
	private SourceListComponent sourceListComponent;

	@PostConstruct
	public void init() {
		setWidth("100.0%");
		setHeight("100.0%");
		setMargin(true);
		buildMainLayout();
	}

	private void buildMainLayout() {
		// initialization layouts
		mainLayout = new HorizontalLayout();
		siteLayout = new VerticalLayout();
		siteDetailLayout = new VerticalLayout();
		filterLayout = new VerticalLayout();

		// do Site layout
		addSiteComposition.setRepaintListener(sourceListComponent);
		siteLayout.addComponent(addSiteComposition);
		siteLayout.addComponent(sourceListComponent);

		mainLayout.addComponent(siteLayout);

		// do Site detail layout
		mainLayout.addComponent(siteDetailLayout);

		// do Filter layout
		mainLayout.addComponent(filterLayout);

		// add mainLayout to Composition
		addComponent(mainLayout);
	}

}
